<template>
    <div>
      <h1>医生信息列表展示</h1>
      <a href="/AddView">医生信息添加</a>
      <br>
      <table class="table">
        <thead>
            <tr>
                <td>医生编号</td>
                <td>医生姓名</td>
                <td>头像</td>
                <td>科室</td>
                <td>创建时间</td>
            </tr>
        </thead>
        <tbody >
            <tr v-for="a in data">
                <td>{{a.id  }}</td>
                <td>{{ a.name }}</td>
                <td><img :src="'https://localhost:7140'+a.img" style="height: 60px;width: 60px;"></td>
                <td>{{ a.cname }}</td>
                <td>{{moment(a.endTime).format("YYYY-MM-DD")  }}</td>
            </tr>
        </tbody>
      </table>
      共{{qwert.totalpage  }}页，共{{qwert.count  }}行，当前第{{find.index  }}页，每页{{find.size  }}行
      <input type="button" value="首页" @click="Fanye(1)">
      <input type="button" value="上一页" @click="Fanye(find.index -1)">
      <input type="button" v-for="m in qwert.totalpage" :value="m" @click="fe(m)">
      <input type="button" value="下一页" @click="Fanye(find.index +1)">
      <input type="button" value="尾页" @click="Fanye(qwert.totalpage)">
      <select v-model="find.size" @click="fs">
        <option :value="2">请选择</option>
        <option :value="3">每页三行</option>
        <option :value="5">每页五行</option>
      </select>
      跳转：
      <input type="number" v-model="tets" >
      <input type="button" value="跳转" @click="Fanye(tets)">
    </div>
</template>

<script setup lang="ts">
import {ref,onMounted} from "vue"
import axios from "axios";
import moment from "moment";
const data=ref([{
    "cid": 3,
      "id": 2,
      "name": "张三",
      "img": "/pic/12a5201b-d328-4748-9221-d24fa22abf2fjerry.jpg",
      "endTime": "2025-05-23T00:00:00",
      "cname": "骨科"
}])
onMounted(()=>{
    Show()
   
})
const fe=(val:any)=>{
   find.value.index=val;
   Show();
}
const Fanye=(val:any)=>{
     if(val>=1 && val<=qwert.value.totalpage){
        find.value.index=val;
        Show()
     }
}
const fs=()=>{
    find.value.index=1
    Show()
}
const Show=()=>{
    axios.get("https://localhost:7140/api/Order/GetOrder",{params:find.value}).then(res=>{
        data.value=res.data.data
        qwert.value.count=res.data.count
        qwert.value.totalpage=Math.ceil(qwert.value.count/find.value.size)
    })
}
const find=ref({
    index:1,
    size:2
})
const qwert=ref({
    count:0,
    totalpage:0
})
</script>

<style scoped>

</style>